import {
  q as o,
  p as N,
  ap as R,
  X as _,
  f as V,
  H as L,
  av as b,
  aw as M,
  k as a,
  m as t,
  az as T,
  as as r,
  aG as O,
  at as v
} from "./index-30f27935.js";
import { k as y } from "./vip-8a4bc37f.js";
function q(A) {
  const h = o([]),
    u = o(!0);
  o({}), N();
  const F = o(1),
    m = o(10),
    p = o({}),
    B = R("reload"),
    g = _({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    x = _({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    D = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "user_id", minWidth: 40 },
      {
        label: "用户",
        prop: "user_name,user_phone",
        minWidth: 80,
        formatter: ({ user_name: e, user_phone: n }) =>
          a("div", null, [
            a("span", null, [t("姓名："), e]),
            a("br", null, null),
            a("span", null, [t("电话："), n])
          ])
      },
      {
        label: "授权人信息",
        prop: "shou_name,shou_phone,shou_card",
        minWidth: 120,
        formatter: ({ shou_name: e, shou_phone: n, shou_card: l }) =>
          a("div", null, [
            a("span", null, [t("姓名："), e]),
            a("br", null, null),
            a("span", null, [t("电话："), n]),
            a("br", null, null),
            a("span", null, [t("身份证："), l])
          ])
      },
      {
        label: "公司信息",
        prop: "faren,name,email,zhizao",
        minWidth: 120,
        formatter: ({ faren: e, name: n, email: l, zhizao: i }) =>
          a("div", null, [
            " ",
            a("span", null, [t("法人："), e]),
            a("br", null, null),
            a("span", null, [t("公司："), n]),
            a("br", null, null),
            a("span", null, [t("邮箱："), l]),
            a("br", null, null),
            a("span", null, [t("营业执照: "), i])
          ])
      },
      { label: "店铺名称", prop: "shop_name", minWidth: 80 },
      {
        label: "营业执照图片",
        prop: "image",
        minWidth: 100,
        cellRenderer: e =>
          a("div", null, [
            " ",
            a(
              "img",
              {
                src: e.row.image,
                style: "width: 150px; height: 100px;",
                alt: ""
              },
              null
            )
          ])
      },
      {
        label: "创建/修改",
        prop: "create_time,update_time",
        minWidth: 120,
        formatter: ({ create_time: e, update_time: n }) =>
          a("div", null, [
            " ",
            a("span", null, [t("创建："), e]),
            a("br", null, null),
            a("span", null, [t("修改："), n || "暂无修改"])
          ])
      },
      { label: "操作", fixed: "right", width: 150, slot: "operation" }
    ],
    w = V(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function C(e) {
    T(e);
  }
  async function S(e) {
    const n = { role_id: e.role_id },
      l = JSON.stringify(n),
      d = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(l)) },
      s = await O(d);
    s.code == 200
      ? (v("删除成功", { type: "success" }), B())
      : v(s.msg, { type: "error" });
  }
  function W() {}
  function z(e) {
    (m.value = e), f(void 0, e);
  }
  function E(e) {
    (F.value = e), f(e, void 0);
  }
  function I(e) {}
  function k(e) {
    (x.text = `正在加载第${e}页...`),
      (u.value = !0),
      b(600).then(() => {
        u.value = !1;
      });
  }
  async function J(e) {
    (u.value = !0), (p.value = e);
    const n = {
        page: 1,
        pagesize: m.value,
        user_phone: e.user_phone,
        shop_name: e.shop_name,
        shou_name: e.shou_name
      },
      l = JSON.stringify(n),
      d = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(l)) },
      { data: s } = await y(d);
    (h.value = s.data),
      (g.total = s.total),
      setTimeout(() => {
        u.value = !1;
      }, 500);
  }
  async function f(e = F.value, n = m.value) {
    const l = {
        page: e,
        pagesize: n,
        user_phone: p.value.user_phone,
        shop_name: p.value.shop_name,
        shou_name: p.value.shou_name
      },
      i = JSON.stringify(l),
      s = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(i)) },
      c = await y(s);
    c.code === 200
      ? ((h.value = c.data.data),
        (g.total = c.data.total),
        setTimeout(() => {
          u.value = !1;
        }, 500))
      : v(c.msg, { type: "error" });
  }
  const U = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    L(() => {
      b().then(() => {
        const { setWatermark: e } = M(A.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        f();
    }),
    {
      loading: u,
      columns: D,
      dataList: h,
      pagination: g,
      buttonClass: w,
      onSearch: J,
      resetForm: U,
      handleaddUser: W,
      handleUpdate: C,
      handleDelete: S,
      handleSizeChange: z,
      handleCurrentChange: E,
      handleSelectionChange: I,
      onCurrentChange: k
    }
  );
}
export { q as useRole };
